<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <!--
    <link href="../static/bootstrap/css/bootstrap-responsive.css" rel="stylesheet" type="text/css"/>
    <link href="../static/bootstrap/css/docs.css" rel="stylesheet" type="text/css"/>
    -->
   <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css"/>
   <link href="/static/viewback/css/mycss.css" rel="stylesheet" type="text/css"/>
   <title>版块删除</title>
</head>
<body>
<div class="header"></div>
<include file="public:header"/>
<ul class="breadcrumb">
    <li>
      <a href="/Admin/user/userList" title="后台管理"><i class="icon-home"></i></a> <span class="divider">/</span>
    </li>
    <li>
      <a href="/Admin/forum/forumList" title="板块管理">版块管理</a> <span class="divider">/</span>
    </li>
    <li class="active" title="板块增加">版块删除</li>
 </ul>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span2">
                <include file="public:leftbar"/>
            </div>
            <div class="span10">
                <div class="well">
                    <fieldset>
                        <legend><h3>版块删除</h3></legend>
                        <form class="form-horizontal" action="/Admin/forum/forumDelete" method="post">
                            <div class="control-group">
                                <label class="control-label" for="parent-forum-name">选择父版块</label>
                                <div class="controls">
                                    <select name="forum_id" id="parent">
                                        <option  value="">
                                            —选择父版块—
                                        </option>
                                        <volist name="parentForum" id="parent">
                                            <option value="{$parent.id}">{$parent.forum_name}</option>
                                        </volist>
                                    </select>
                                    <input type="submit" value="删除父版块" class="btn btn-danger" onclick="return confirm('该版块下的所有子版块将一起删除，确定删除？');"/>
                                </div>
                            </div>
                        </form>
                        <form class="form-horizontal" action="/Admin/forum/forumDelete" method="post" id="child-form">
                            <div class="control-group">
                                <label class="control-label">选择子版块</label>
                                <div class="controls">
                                    <select name="forum_id" id="child">
                                        <option value="">—选择子版块—</option>
                                    </select>
                                    <input type="submit" value="删除子版块" class="btn btn-danger" onclick="return confirm('确定删除？');"/>
                                </div>
                            </div>
                        </form>
                        <div class="form-actions">
                           &nbsp;{$msg}
                        </div>
                    </fieldset>
                </div>
            </div>
        </div>
</div>
<div class="footer"></div>
<include file="public:footer"/>
<script type="text/javascript" src="/static/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="/static/viewback/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
       $('form:first').submit(function(){
           if($('#parent').val()==''){
               alert('请选择要删除的版块');
               return false;
           }
       });
       $('form#child-form').submit(function(){
           if($('#child').val()==''){
               alert('请选择要删除的版块');
               return false;
           }
       });
       //ajax两级联动
       $('#parent').change(function(){
           $.ajax({
                url:'/Admin/forum/getChildByParent',
                data:$('form:first').serialize(),
                type:'post',
                dataType:'json',
                success:function(data){
                    var len=data.length;
                    $('#child').html("<option value=''>—选择子版块—</option>");//每次添加新的记录时清除前一次添加的记录
                    for(var i=0;i<len;i++){
                        $('#child').append("<option value='"+data[i].id+"'>"+data[i].forum_name+"</option>");
                    }
                },
                error:function(){
                    alert('an error occured');
                }
           });   
       });
       
    });
</script>
</body>
</html>

